<?php

use Biz\service\brand\Brand as sBrand;
use Biz\service\wiki\Wiki as sWiki;
use Doraemon\model\Category as mCategory;

class GetWikiByLinkAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REALNAME;

    public function main()
    {
        $content = $this->getRequest()->getPost('content', '');
        $objType = $this->getRequest()->getPost('obj_type', 1);
        $type = $this->getRequest()->getPost('type', 0);
        $isPreCreate = $this->getRequest()->getPost('pre_create', 1);
        $isPreCreate = (bool)$isPreCreate;
        try {
            $result = sWiki::getWikiByLinkForApi($content, $type, $objType, null, $isPreCreate);
            $this->setSuccess($result);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode());
        }
    }
}